package com.qf.service.impl;

import com.qf.dao.HouseMapper;
import com.qf.pojo.House;
import com.qf.pojo.HouseExample;
import com.qf.pojo.Repair;
import com.qf.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class HouseServiceImpl implements HouseService {
    @Autowired
    private HouseMapper houseMapper;
    @Override
    public List<House> findAll() {
//        HouseExample houseExample = new HouseExample();
//        HouseExample.Criteria criteria = houseExample.createCriteria();
//        criteria.andCommunityIdEqualTo(1);
//        criteria.andHouseNumberEqualTo("12121");
//        List<House> houses = houseMapper.selectByExample(houseExample);
//        houses.get(0);

        houseMapper.selectByExample(null);
//        houseMapper.selectByPrimaryKey(id);


        return null;

    }

    @Override
    public void saveOrUpdateRepair(House house) {
        if (house.getId() == null) {
            //新增
            houseMapper.insert(house);
        }else {
            System.out.println("111111");

            houseMapper.updateByPrimaryKey(house);
        }

    }





    // 根据id查询
    @Override
    public House findByHouseId(String id) {
        return houseMapper.selectByPrimaryKey(Integer.parseInt(id));
    }

    //删除
    @Override
    public Integer deleteHouse(String id) {
        return houseMapper.deleteByPrimaryKey(Integer.parseInt(id));
    }


}
